<?php

function debug($var,$nombre="")
{
  global $debug, $firephp;
  if($debug)
    $firephp->log($var, $nombre);
}

function getmicrotime() 
{
  list($usec, $sec) = explode(" ", microtime());
  return ((float)$usec + (float)$sec); 
}

function iniciarFirebug()
{
  global $firephp;
  require_once 'lib/FirePHPCore-0.3.1/FirePHP.class.php';
  $firephp = FirePHP::getInstance(true);
  ob_start();
}

function session($variable , $valorpordefecto=null)
{
  return isset($_SESSION[$variable]) ? $_SESSION[$variable]: $valorpordefecto;
}

function post($variable , $valorpordefecto=null)
{
  return isset($_POST[$variable]) ? $_POST[$variable]: $valorpordefecto;
}

function get($variable , $valorpordefecto=null)
{
  return isset($_GET[$variable]) ? $_GET[$variable]: $valorpordefecto;
}

function tr($tex_id)
{
  $txt = @consultarCampo(sqlselect("tex_{$_SESSION['idioma']}",'texto',where(array('tex_id'=>$tex_id)),true));
  if(is_null($txt))
    return $tex_id;
  else
    return $txt;
}